package com.foldingleaf.web.controller.recharge;

import com.foldingleaf.common.annotation.Log;
import com.foldingleaf.common.core.controller.BaseController;
import com.foldingleaf.common.core.domain.Result;
import com.foldingleaf.common.core.page.TableDataInfo;
import com.foldingleaf.common.enums.BusinessType;
import com.foldingleaf.common.utils.poi.ExcelUtil;
import com.foldingleaf.recharge.domain.AlipayRechargeOrder;
import com.foldingleaf.recharge.service.IAlipayRechargeOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 支付宝充值订单Controller
 * 
 * @author ajian
 * @date 2022-06-17
 */
@Api(value = "/recharge/recharge", tags = {"支付宝充值订单Controller"})
@RestController
@RequestMapping("/recharge/recharge")
public class AlipayRechargeOrderController extends BaseController
{
    @Autowired
    private IAlipayRechargeOrderService alipayRechargeOrderService;

    /**
     * 查询支付宝充值订单列表
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "AlipayRechargeOrder", name = "alipayRechargeOrder", value = "")
    })
    @ApiOperation(value = "查询支付宝充值订单列表", notes = "查询支付宝充值订单列表", httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('recharge:recharge:list')")
    @GetMapping("/list")
    public TableDataInfo list(AlipayRechargeOrder alipayRechargeOrder)
    {
        startPage();
        List<AlipayRechargeOrder> list = alipayRechargeOrderService.selectAlipayRechargeOrderList(alipayRechargeOrder);
        return getDataTable(list);
    }

    /**
     * 导出支付宝充值订单列表
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "HttpServletResponse", name = "response", value = ""),
            @ApiImplicitParam(paramType = "query", dataType = "AlipayRechargeOrder", name = "alipayRechargeOrder", value = "")
    })
    @ApiOperation(value = "导出支付宝充值订单列表", notes = "导出支付宝充值订单列表", httpMethod = "POST")
    @PreAuthorize("@ss.hasPermi('recharge:recharge:export')")
    @Log(title = "支付宝充值订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlipayRechargeOrder alipayRechargeOrder)
    {
        List<AlipayRechargeOrder> list = alipayRechargeOrderService.selectAlipayRechargeOrderList(alipayRechargeOrder);
        ExcelUtil<AlipayRechargeOrder> util = new ExcelUtil<AlipayRechargeOrder>(AlipayRechargeOrder.class);
        util.exportExcel(response, list, "支付宝充值订单数据");
    }

    /**
     * 获取支付宝充值订单详细信息
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "orderId", value = "")
    })
    @ApiOperation(value = "获取支付宝充值订单详细信息", notes = "获取支付宝充值订单详细信息", httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('recharge:recharge:query')")
    @GetMapping(value = "/{orderId}")
    public Result getInfo(@PathVariable("orderId") Long orderId)
    {
        return Result.success(alipayRechargeOrderService.selectAlipayRechargeOrderByOrderId(orderId));
    }

    /**
     * 新增支付宝充值订单
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "AlipayRechargeOrder", name = "alipayRechargeOrder", value = "")
    })
    @ApiOperation(value = "新增支付宝充值订单", notes = "新增支付宝充值订单", httpMethod = "POST")
    @PreAuthorize("@ss.hasPermi('recharge:recharge:add')")
    @Log(title = "支付宝充值订单", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody AlipayRechargeOrder alipayRechargeOrder)
    {
        return toAjax(alipayRechargeOrderService.insertAlipayRechargeOrder(alipayRechargeOrder));
    }

    /**
     * 修改支付宝充值订单
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "AlipayRechargeOrder", name = "alipayRechargeOrder", value = "")
    })
    @ApiOperation(value = "修改支付宝充值订单", notes = "修改支付宝充值订单", httpMethod = "PUT")
    @PreAuthorize("@ss.hasPermi('recharge:recharge:edit')")
    @Log(title = "支付宝充值订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody AlipayRechargeOrder alipayRechargeOrder)
    {
        return toAjax(alipayRechargeOrderService.updateAlipayRechargeOrder(alipayRechargeOrder));
    }

    /**
     * 删除支付宝充值订单
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "Long[]", name = "orderIds", value = "")
    })
    @ApiOperation(value = "删除支付宝充值订单", notes = "删除支付宝充值订单", httpMethod = "DELETE")
    @PreAuthorize("@ss.hasPermi('recharge:recharge:remove')")
    @Log(title = "支付宝充值订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public Result remove(@PathVariable Long[] orderIds)
    {
        return toAjax(alipayRechargeOrderService.deleteAlipayRechargeOrderByOrderIds(orderIds));
    }
}
